﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web;
using HandBook.Data;
using HandBook.Entities;

/// <summary>
/// Summary description for SessionManager
/// </summary>
public static class SessionManager
{
    public static User CurrentUser
    {
        get
        {
            if (HttpContext.Current.Session["CurrentUser"] != null)
            {
                return (User)HttpContext.Current.Session["CurrentUser"];
            }
            else
            {
                FormsAuthentication.SignOut();
                HttpContext.Current.Response.Redirect(FormsAuthentication.LoginUrl);
                return null;
            }

        }
        set
        {
            HttpContext.Current.Session["CurrentUser"] = value;
        }
    }

    public static Search CurrentSearch
    {
        get
        {
            if (HttpContext.Current.Session["CurrentSearch"] != null)
                return (Search)HttpContext.Current.Session["CurrentSearch"];
            return new Search();

        }
        set
        {
            HttpContext.Current.Session["CurrentSearch"] = value;
        }
    }
}
